﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class HypedArtist : LastfmModelBase, IHasFiveImages, IArtist, IHyped
    {
        public HypedArtist()
        {
            this.Name = string.Empty;
            this.PercentageChange = 0;
            this.Mbid = string.Empty;
            this.Url = string.Empty;
            this.Streamable = false;
            this.ImageSmall = string.Empty;
            this.ImageMedium = string.Empty;
            this.ImageLarge = string.Empty;
            this.ImageExtralarge = string.Empty;
            this.ImageMega = string.Empty;
        }

        public HypedArtist(XmlNode artistNode)
        : this()
        {
            if (artistNode == null) return;
            else this.InitializeFromXmlNode(artistNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.Name = node.GetChildValue("name");
            this.PercentageChange = node.GetChildValue("playcount").ToInteger();
            this.Mbid = node.GetChildValue("mbid");
            this.Url = node.GetChildValue("url");
            this.Streamable = node.GetChildValue("streamable").ToBoolean();
            this.ImageSmall = node.GetChildValueWithSpecialAtrribute("image", "size", "small");
            this.ImageMedium = node.GetChildValueWithSpecialAtrribute("image", "size", "medium");
            this.ImageLarge = node.GetChildValueWithSpecialAtrribute("image", "size", "large");
            this.ImageExtralarge = node.GetChildValueWithSpecialAtrribute("image", "size", "extralarge");
            this.ImageMega = node.GetChildValueWithSpecialAtrribute("image", "size", "mega");
        }

        public string Name { get; set; }

        public int PercentageChange { get; set; }

        public string Mbid { get; set; }

        public string Url { get; set; }

        public bool Streamable { get; set; }

        public string ImageSmall { get; set; }

        public string ImageMedium { get; set; }

        public string ImageLarge { get; set; }

        public string ImageExtralarge { get; set; }

        public string ImageMega { get; set; }
    }
}
